package com.chuangtie.tlcms.saturn.interfaces.controller;

import com.chuangtie.secondary.lining.common.response.OpenResponse;
import com.chuangtie.tlcms.saturn.application.request.PropertyCommand;
import com.chuangtie.tlcms.saturn.application.request.PropertyQueryCommand;
import com.chuangtie.tlcms.saturn.application.response.PropertyInfoDTO;
import com.chuangtie.tlcms.saturn.application.service.PropertyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

/**
 * @Author: 廖智威
 * @CreateTime: 2024-07-09
 */
@RestController
@RequestMapping ("/property")
@AllArgsConstructor
@Api(tags = "工程初始化相关接口")
public class PropertyController {

    private final PropertyService propertyService;

    @PostMapping("/infoList")
    @ApiOperation(value = "工程信息列表")
    public OpenResponse<List<PropertyInfoDTO>> propertyInfoList(@RequestBody @Valid PropertyQueryCommand requestParam) {
        return new OpenResponse<>(propertyService.propertyInfoList(requestParam));
    }

    @PostMapping("/create")
    @ApiOperation(value = "创建工程")
    public OpenResponse<Boolean> createProperty(@RequestBody @Valid PropertyCommand requestParam) {
        return new OpenResponse<>(propertyService.createProperty(requestParam));
    }
}
